package cn.tpshion.vm.base.interceptor;

import cn.dev33.satoken.fun.SaParamFunction;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.tpshion.vm.common.constant.InterceptOrder;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.Ordered;

public class AuthInterceptor extends SaInterceptor implements Ordered {

    public AuthInterceptor(SaParamFunction<Object> auth) {
        super(auth);
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String servletPath = request.getServletPath();
        if(servletPath.contains(".")){
            return true;
        }
        return super.preHandle(request, response, handler);
    }

    @Override
    public int getOrder() {
        return InterceptOrder.AUTH_INTERCEPTOR.getOrder();
    }
}
